unit Class_GKXVOCHDATA;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TVOCHDATA=class(TUniEngine)
  private
    FGKJGIDEX: Integer;
    FUNITLINK: string;
    FGKJLIDEX: Integer;
    FGKJLFLID: Integer;
    FPZDWBML: string;
    FPZKJQJBH: Integer;                      
    FPZSBH: Integer;
    FPZBH: Integer;
    FPZROLE: string;
    FVOCHTIME: TDateTime;
    FVOCHCZY: string;
    FVOCHMONY: Extended;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property GKJGIDEX: Integer read FGKJGIDEX write FGKJGIDEX;
    property UNITLINK: string read FUNITLINK write FUNITLINK;
    property GKJLIDEX: Integer read FGKJLIDEX write FGKJLIDEX;
    property GKJLFLID: Integer read FGKJLFLID write FGKJLFLID;
    property PZDWBML: string read FPZDWBML write FPZDWBML;
    property PZKJQJBH: Integer read FPZKJQJBH write FPZKJQJBH;
    property PZSBH: Integer read FPZSBH write FPZSBH;
    property PZBH: Integer read FPZBH write FPZBH;
    property PZROLE: string read FPZROLE write FPZROLE;
    property VOCHTIME: TDateTime read FVOCHTIME write FVOCHTIME;
    property VOCHCZY: string read FVOCHCZY write FVOCHCZY;
    property VOCHMONY: Extended read FVOCHMONY write FVOCHMONY;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AVOCHDATA:TVOCHDATA):TVOCHDATA;overload;        
    class procedure CopyIt(AVOCHDATA:TVOCHDATA;var Result:TVOCHDATA);overload;       
  end;

implementation

{ TVOCHDATA }
procedure TVOCHDATA.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('GKJG_IDEX').Value := GKJGIDEX;
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('GKJL_IDEX').Value := GKJLIDEX;
        ParamByName('GKJL_FLID').Value := GKJLFLID;
        ParamByName('PZ_DWBML').Value := PZDWBML;
        ParamByName('PZ_KJQJ_BH').Value := PZKJQJBH;
        ParamByName('PZ_SBH').Value := PZSBH;
        ParamByName('PZ_BH').Value := PZBH;
        ParamByName('PZ_ROLE').Value := PZROLE;
        ParamByName('VOCH_TIME').Value := VOCHTIME;
        ParamByName('VOCH_CZY').Value := VOCHCZY;
        ParamByName('VOCH_MONY').Value := VOCHMONY; 
      end;
      otEdit:
      begin
        ParamByName('GKJG_IDEX').Value := GKJGIDEX;
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('GKJL_IDEX').Value := GKJLIDEX;
        ParamByName('GKJL_FLID').Value := GKJLFLID;
        ParamByName('PZ_DWBML').Value := PZDWBML;
        ParamByName('PZ_KJQJ_BH').Value := PZKJQJBH;
        ParamByName('PZ_SBH').Value := PZSBH;
        ParamByName('PZ_BH').Value := PZBH;
        ParamByName('PZ_ROLE').Value := PZROLE;
        ParamByName('VOCH_TIME').Value := VOCHTIME;
        ParamByName('VOCH_CZY').Value := VOCHCZY;
        ParamByName('VOCH_MONY').Value := VOCHMONY; 
      end;  
      otDelt:
      begin
        ParamByName('GKJG_IDEX').Value := GKJGIDEX;
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('GKJL_IDEX').Value := GKJLIDEX;
        ParamByName('GKJL_FLID').Value := GKJLFLID;
        ParamByName('PZ_DWBML').Value := PZDWBML;
        ParamByName('PZ_KJQJ_BH').Value := PZKJQJBH;
        ParamByName('PZ_SBH').Value := PZSBH;
        ParamByName('PZ_BH').Value := PZBH;
        ParamByName('PZ_ROLE').Value := PZROLE;
 
      end;  
    end;
  end;
end;

function TVOCHDATA.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('GKX_VOCH_DATA',['GKJG_IDEX',GKJGIDEX,'UNIT_LINK',UNITLINK,'GKJL_IDEX',GKJLIDEX,'GKJL_FLID',GKJLFLID,'PZ_DWBML',PZDWBML,'PZ_KJQJ_BH',PZKJQJBH,'PZ_SBH',PZSBH,'PZ_BH',PZBH,'PZ_ROLE',PZROLE],AUniConnection);
end;

function TVOCHDATA.GetNextIdex: Integer;
begin

end;

function TVOCHDATA.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TVOCHDATA.GetStrDelete: string;
begin
  Result:='DELETE FROM GKX_VOCH_DATA WHERE   GKJG_IDEX=:GKJG_IDEX AND UNIT_LINK=:UNIT_LINK AND GKJL_IDEX=:GKJL_IDEX AND GKJL_FLID=:GKJL_FLID AND PZ_DWBML=:PZ_DWBML AND PZ_KJQJ_BH=:PZ_KJQJ_BH AND PZ_SBH=:PZ_SBH AND PZ_BH=:PZ_BH AND PZ_ROLE=:PZ_ROLE';
end;

function TVOCHDATA.GetStrInsert: string;
begin
  Result:='INSERT INTO GKX_VOCH_DATA'
         +'    ( GKJG_IDEX, UNIT_LINK, GKJL_IDEX, GKJL_FLID, PZ_DWBML'
         +'    , PZ_KJQJ_BH, PZ_SBH, PZ_BH, PZ_ROLE, VOCH_TIME, VOCH_CZY'
         +'    , VOCH_MONY)'
         +'    VALUES'
         +'    (:GKJG_IDEX,:UNIT_LINK,:GKJL_IDEX,:GKJL_FLID,:PZ_DWBML'
         +'    ,:PZ_KJQJ_BH,:PZ_SBH,:PZ_BH,:PZ_ROLE,:VOCH_TIME,:VOCH_CZY'
         +'    ,:VOCH_MONY)';
end;

function TVOCHDATA.GetStrsIndex: string;
begin
  Result:=Format('%D-%S-%D-%D-%S-%D-%D-%D-%S',[GKJGIDEX,UNITLINK,GKJLIDEX,GKJLFLID,PZDWBML,PZKJQJBH,PZSBH,PZBH,PZROLE]);
end;

function TVOCHDATA.GetStrUpdate: string;
begin
  Result:='UPDATE  GKX_VOCH_DATA SET'
         +'    VOCH_TIME=:VOCH_TIME,'
         +'    VOCH_CZY=:VOCH_CZY,'
         +'    VOCH_MONY=:VOCH_MONY'
         +'    WHERE GKJG_IDEX=:GKJG_IDEX'
         +'    AND   UNIT_LINK=:UNIT_LINK'
         +'    AND   GKJL_IDEX=:GKJL_IDEX'
         +'    AND   GKJL_FLID=:GKJL_FLID'
         +'    AND   PZ_DWBML=:PZ_DWBML'
         +'    AND   PZ_KJQJ_BH=:PZ_KJQJ_BH'
         +'    AND   PZ_SBH=:PZ_SBH'
         +'    AND   PZ_BH=:PZ_BH'
         +'    AND   PZ_ROLE=:PZ_ROLE';
end;

constructor TVOCHDATA.Create;
begin

end;

destructor TVOCHDATA.Destroy;
begin

  inherited;
end;

class function TVOCHDATA.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TVOCHDATA.Create;
  with TVOCHDATA(Result) do
  begin
    GKJGIDEX:=AUniQuery.FieldByName('GKJG_IDEX').AsInteger;
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    GKJLIDEX:=AUniQuery.FieldByName('GKJL_IDEX').AsInteger;
    GKJLFLID:=AUniQuery.FieldByName('GKJL_FLID').AsInteger;
    PZDWBML:=AUniQuery.FieldByName('PZ_DWBML').AsString;
    PZKJQJBH:=AUniQuery.FieldByName('PZ_KJQJ_BH').AsInteger;
    PZSBH:=AUniQuery.FieldByName('PZ_SBH').AsInteger;
    PZBH:=AUniQuery.FieldByName('PZ_BH').AsInteger;
    PZROLE:=AUniQuery.FieldByName('PZ_ROLE').AsString;
    VOCHTIME:=AUniQuery.FieldByName('VOCH_TIME').AsDateTime;
    VOCHCZY:=AUniQuery.FieldByName('VOCH_CZY').AsString;
    VOCHMONY:=AUniQuery.FieldByName('VOCH_MONY').AsFloat;
  end;  
end;

class procedure TVOCHDATA.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TVOCHDATA(Result) do
  begin
    GKJGIDEX:=AUniQuery.FieldByName('GKJG_IDEX').AsInteger;
    UNITLINK:=AUniQuery.FieldByName('UNIT_LINK').AsString;
    GKJLIDEX:=AUniQuery.FieldByName('GKJL_IDEX').AsInteger;
    GKJLFLID:=AUniQuery.FieldByName('GKJL_FLID').AsInteger;
    PZDWBML:=AUniQuery.FieldByName('PZ_DWBML').AsString;
    PZKJQJBH:=AUniQuery.FieldByName('PZ_KJQJ_BH').AsInteger;
    PZSBH:=AUniQuery.FieldByName('PZ_SBH').AsInteger;
    PZBH:=AUniQuery.FieldByName('PZ_BH').AsInteger;
    PZROLE:=AUniQuery.FieldByName('PZ_ROLE').AsString;
    VOCHTIME:=AUniQuery.FieldByName('VOCH_TIME').AsDateTime;
    VOCHCZY:=AUniQuery.FieldByName('VOCH_CZY').AsString;
    VOCHMONY:=AUniQuery.FieldByName('VOCH_MONY').AsFloat;
  end;  
end;

class function  TVOCHDATA.CopyIt(AVOCHDATA: TVOCHDATA): TVOCHDATA;
begin
  Result:=TVOCHDATA.Create;
  TVOCHDATA.CopyIt(AVOCHDATA,Result)
end;

class procedure TVOCHDATA.CopyIt(AVOCHDATA:TVOCHDATA;var Result:TVOCHDATA);
begin
  if Result=nil then Exit;
  Result.GKJGIDEX:=AVOCHDATA.GKJGIDEX;
  Result.UNITLINK:=AVOCHDATA.UNITLINK;
  Result.GKJLIDEX:=AVOCHDATA.GKJLIDEX;
  Result.GKJLFLID:=AVOCHDATA.GKJLFLID;
  Result.PZDWBML:=AVOCHDATA.PZDWBML;
  Result.PZKJQJBH:=AVOCHDATA.PZKJQJBH;
  Result.PZSBH:=AVOCHDATA.PZSBH;
  Result.PZBH:=AVOCHDATA.PZBH;
  Result.PZROLE:=AVOCHDATA.PZROLE;
  Result.VOCHTIME:=AVOCHDATA.VOCHTIME;
  Result.VOCHCZY:=AVOCHDATA.VOCHCZY;
  Result.VOCHMONY:=AVOCHDATA.VOCHMONY;
end;

end.
